package com.mistyrain.controller;

import com.mistyrain.entity.Account;
import com.mistyrain.entity.Admin;
import com.mistyrain.entity.User;
import com.mistyrain.feign.AccountFeign;
import com.mistyrain.service.AccountService;
import com.mistyrain.utils.ReflectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;

@Controller
@RequestMapping("/account")
public class AccountHandler {

    @Autowired
    private AccountService accountService;

    @PostMapping("/login")
    public String login(@RequestParam("username") String username, @RequestParam("password") String password, @RequestParam("type") String type, HttpSession session){
        return accountService.login(username, password, type,session);
    }

    @GetMapping("/logout")
    public String logout(HttpSession session){
        return accountService.logout(session);
    }

    @RequestMapping("/redirect/{target}")
    public String redirect(@PathVariable("target") String target){
        return target;
    }


}

